package com.myblog.myblog.controller;

import com.myblog.myblog.domain.BOtherpage;
import com.myblog.myblog.service.OtherPageService;
import com.myblog.myblog.utils.ResultData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @auther gyl
 * @data 2019.11.26 16:47
 */
@RestController
@RequestMapping("otherpage")
public class OtherpageController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    OtherPageService otherPageService;
    @Autowired
    private RedisTemplate redisTemplate;

    @PostMapping(value = "/test")
    @ResponseBody
    public Object test(){
        logger.info("===================测试测试测试werwqqeweqwe------------===============");
        BOtherpage b = new BOtherpage();
        b.setId("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
        b.setOtherpageCount("qwe");
        b.setOtherpageName("123");
        b.setOtherpageSrc("111");
//        mapper.insert(b);
//        logger.info("id======"+IdUtil.simpleUUID());
        redisTemplate.opsForValue().set("name-1", "张三");

        System.out.println("---"+redisTemplate.opsForValue().get("name-1"));

        return b;
    }

    @PostMapping(value = "/addOtherpage")
    @ResponseBody
    public Object addOtherpage(@RequestBody BOtherpage bOtherpage){
        otherPageService.insertOtherPage(bOtherpage);
        return null;
    }

    @PostMapping(value = "/selectAll")
    @ResponseBody
    public ResultData selectAll(){
        List otherpage = otherPageService.selectAll();
        return ResultData.success(otherpage);
    }

}